package nc.bs.pub.action;

import nc.bs.framework.common.NCLocator;
import nc.bs.pub.action.listener.IPWgCcpAllServer;
import nc.itf.ic.m46.IProductInMaitain;
import nc.itf.mmpac.pmo.pac0002.IPMOMaintainService;
import nc.itf.mmpac.wr.IWrBusinessService;
import nc.itf.mmpac.wr.pwr.IPwrMaintainService;
import nc.itf.uap.pf.IPFBusiAction;
import nc.itf.uap.pf.IplatFormEntry;
import nc.vo.ic.m46.entity.FinProdInVO;
import nc.vo.mmpac.wr.entity.AggWrVO;
import nc.vo.pub.lang.UFDouble;

/**
 * 
 * 
 * @author LP
 *
 */

public class IPWgCcpAllImpl implements IPWgCcpAllServer {

	@Override
	public void IPWgCcpAll_RequiresNew(AggWrVO[] wrVOs) throws Exception {
		
		AggWrVO[] aggWrVOs = NCLocator.getInstance().lookup(IPwrMaintainService.class).insert_RequiresNew(wrVOs);
//		AggWrVO[] aggWrVOs = (AggWrVO[])NCLocator.getInstance().lookup(IPFBusiAction.class).processAction("SAVE", wrVOs[0].getParentVO().getVtrantypecode(), null,wrVOs[0], null, null);
		
		AggWrVO[] aggWrVOs2 = (AggWrVO[])NCLocator.getInstance().lookup(IplatFormEntry.class).processAction("APPROVE", aggWrVOs[0].getParentVO().getVtrantypecode(), null, aggWrVOs[0], null, null);
		int a= wrVOs[0].getChildrenVO().length;
		
		//for(int i=0;i<a;i++) {
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setNgtoinastnum(new UFDouble(wrVOs[0].getChildrenVO()[0].getAttributeValue("ngtoinastnum").toString()));
		
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setNgtoinnum(new UFDouble(wrVOs[0].getChildrenVO()[0].getAttributeValue("ngtoinastnum").toString()));
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setNginnum(new UFDouble(wrVOs[0].getChildrenVO()[0].getAttributeValue("ngtoinastnum").toString()));
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setNginastnum(new UFDouble(wrVOs[0].getChildrenVO()[0].getAttributeValue("ngtoinastnum").toString()));
		
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setCgdepositorgid(wrVOs[0].getParentVO().getPk_org());
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setCgdepositorgvid(wrVOs[0].getParentVO().getPk_org());
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setCgwarehouseid(wrVOs[0].getChildrenVO()[0].getAttributeValue("cgwarehouseid").toString());
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setVginstockbid(wrVOs[0].getChildrenVO()[0].getVbbatchid());
		aggWrVOs2[0].getChildrenVO()[0].getQualityvos()[0].setVginstockbcode(wrVOs[0].getChildrenVO()[0].getVbbatchcode());


	//	}
		NCLocator.getInstance().lookup(IWrBusinessService.class).prodIn(aggWrVOs2);
	}
}

